/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Entidades;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author ccedeno
 */
@Entity
@Table(name = "tipo_doc_interno", catalog = "emilima_tradoc", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "TipoDocInterno.findAll", query = "SELECT t FROM TipoDocInterno t"),
    @NamedQuery(name = "TipoDocInterno.findByIdTipoDocInterno", query = "SELECT t FROM TipoDocInterno t WHERE t.idTipoDocInterno = :idTipoDocInterno"),
    @NamedQuery(name = "TipoDocInterno.findByNombre", query = "SELECT t FROM TipoDocInterno t WHERE t.nombre = :nombre")})
public class TipoDocInterno implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 3)
    @Column(name = "id_tipo_doc_interno", nullable = false, length = 3)
    private String idTipoDocInterno;
    @Size(max = 45)
    @Column(name = "nombre", length = 45)
    private String nombre;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "tipoDocInterno", fetch = FetchType.LAZY)
    private List<MovExp> movExpList;
    @JoinColumn(name = "fk_estado", referencedColumnName = "id_estado", nullable = false)
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Estado estado;

    public TipoDocInterno() {
    }

    public TipoDocInterno(String idTipoDocInterno) {
        this.idTipoDocInterno = idTipoDocInterno;
    }

    public String getIdTipoDocInterno() {
        return idTipoDocInterno;
    }

    public void setIdTipoDocInterno(String idTipoDocInterno) {
        this.idTipoDocInterno = idTipoDocInterno;
    }

    public String getNombre() {
        return nombre;
    }

    public void setNombre(String nombre) {
        this.nombre = nombre;
    }

    @XmlTransient
    public List<MovExp> getMovExpList() {
        return movExpList;
    }

    public void setMovExpList(List<MovExp> movExpList) {
        this.movExpList = movExpList;
    }

    public Estado getEstado() {
        return estado;
    }

    public void setEstado(Estado estado) {
        this.estado = estado;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idTipoDocInterno != null ? idTipoDocInterno.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof TipoDocInterno)) {
            return false;
        }
        TipoDocInterno other = (TipoDocInterno) object;
        if ((this.idTipoDocInterno == null && other.idTipoDocInterno != null) || (this.idTipoDocInterno != null && !this.idTipoDocInterno.equals(other.idTipoDocInterno))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
//        return "Entidades.TipoDocInterno[ idTipoDocInterno=" + idTipoDocInterno + " ]";
        return  idTipoDocInterno + "  "+nombre;        
    }
}
